import { Injectable } from '@nestjs/common';
import { Express } from 'express';
import { ConfigService } from '@nestjs/config';


@Injectable()
export class FileService {
  constructor(
    private config: ConfigService
  ) { }

  // 生成文件访问URL（如：http://localhost:3000/uploads/abc.jpg）
  getFileUrl(filename: string): string {
    const serverUrl = this.config.get('SERVER_URL', 'http://localhost:3000');
    return `${serverUrl}/uploads/${filename}`;
  }

  // 验证文件类型（可选）
  validateFileType(file: any, allowedTypes: string[]): boolean {
    return allowedTypes.includes(file.mimetype);
  }
}
